import type { CartInfo } from '@/types/cart.t'
import { http } from '@/utils/http'
interface CartItem {
  skuId: string
  count: number
}

export const postMemberCartApi = (data: CartItem) => {
  return http({
    method: 'POST',
    url: '/member/cart',
    data,
  })
}
export const getMemberCartApi = () => {
  return http<CartInfo[]>({
    method: 'GET',
    url: '/member/cart',
  })
}

/**删除购物车单品 */
export const deleteMemberCartApi = (data: { ids: string[] }) => {
  return http({
    method: 'DELETE',
    url: '/member/cart',
    data,
  })
}
/**修改购物车单品数量 */
export const putMemberCartApi = (sukid: string, data?: { count?: number; selected?: boolean }) => {
  return http({
    method: 'PUT',
    url: `/member/cart/${sukid}`,
    data,
  })
}
// 购物车全选/取消全选
export const PutMemberAllCartSelected = (data: { selected: boolean }) => {
  return http<{ id: string }>({
    method: 'PUT',
    url: '/member/cart/selected',
    data,
  })
}
